<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./vue.js"></script>
    <style>
      .actived {
        color: red;
        background-color: aqua;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <div v-for="item in arr" :key="item.id">
        <h1>{{item}}</h1>
      </div>
      <button @click="aaa">添加</button>
    </div>

    <script>
      var app = new Vue({
        el: "#app",
        data: {
          arr: [
            {
              id: 1,
              fruit: "苹果",
            },
            {
              id: 2,
              fruit: "香蕉",
            },
            {
              id: 3,
              fruit: "橙子",
            },
          ],
        },
        methods: {
          aaa() {
            //这一步是常规方法  先试试这个   大多数程序员想到的
            this.arr[2].color='黄色香蕉'
            app.$set(app.arr,this.color,'黄色香蕉')
            console.log(this.arr);
          },
        },
      });
      console.log(app);
    </script>
  </body>
</html>
